﻿@{
    Layout = null;
}
@{
    ViewData["Title"] = "管理员列表";
    var role = ViewBag.role as List<BuyWithoutLoseMoney.Core.Models.Role>;
    var loginUserRole = ViewBag.LoginUserRole as List<BuyWithoutLoseMoney.Core.Models.LoginUserRole>;

}
@model List<BuyWithoutLoseMoney.Core.Models.LoginUser>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="/layui/css/layui.mobile.css" rel="stylesheet" />
    <link href="/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    <div class="layui-form">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="150">
                <col width="200">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th>管理员名</th>
                    <th>角色名</th>
                    <th>操作</th>

                </tr>
            </thead>
            <tbody>
                @foreach (var item in loginUserRole.Where(x => x.LoginUserId == ViewBag.Id))
                {
                    <form class="layui-form">

                    <tr>
                        <td name="LoginUserId" >@item.LoginUser.LoginName</td>
                        <td name="RoleId" >@item.Role.Name </td>
                        <td>
                                 @*<a lay-event="del" class='layui-btn layui-btn-warm layui-btn-sm'>删除角色</a>*@
                                @*<button type="submit" class="el-button el-button-primary">删除</button>*@
                                <button lay-submit lay-filter="del" class="layui-btn layui-btn-danger" style="float:right">删除</button>
                        </td>
                    </tr>
                    </form>

                }

            </tbody>
        </table>

    </div>
    <script src="/js/vue.js"></script>
    <script src="/layui/layui.js"></script>

    <script>
        layui.use(["form", 'layer'], function() {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            form.on('submit(del)', function(data) {
                console.log(data)
                $.post("/admin/management/del", data.field, function(res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function() {
                            parent.window.location.href = "/admin/management/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
    @* <script>
    layui.use('table', function() {
    var table = layui.table;

    ////单元格工具事件
    table.on('tool(test)', function(obj) { // 注：test 是 table 原始标签的属性 lay-filter="对应的值"
    var data = obj.data; //获得当前行数据
    var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
    var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

    if (layEvent === 'del') { //删除
    layer.confirm('确定删除吗？', function(index) {
    $.post("/admin/Management/del", data.field, function(res) {
    if (res.isSuccess) {
    layer.msg(res.msg, function() {
    parent.window.location.href = "/admin/management/index";
    });
    } else {
    layer.msg(res.msg);
    }
    });
    });
    }
    });

    });
    </script>*@
</body>
</html>